package cn.yzstu.finaltest;

import java.util.Date;

/**
 * @author Baldwin
 */
public class FinalTestA {

    public static final int N_ITERATIONS = 1000000;

    public static String testFinal() {
        final Date date = new Date();
//        final String a = "Baldwin";
//        final String b = "keep mind";

        return date.toString();
    }

    public static String testNonFinal() {
        Date date = new Date();
//        String a = "Baldwin";
//        String b = "keep mind";
        return date.toString();
    }

    public static void main(String[] args) {
        long tStart, tElapsed;


        tStart = System.currentTimeMillis();
        for (int i = 0; i < N_ITERATIONS; i++) {
            testFinal();
        }
        tElapsed = System.currentTimeMillis() - tStart;
        System.out.println("Method with finals took " + tElapsed + " ms");

        tStart = System.currentTimeMillis();
        for (int i = 0; i < N_ITERATIONS; i++) {
            testNonFinal();
        }
        tElapsed = System.currentTimeMillis() - tStart;
        System.out.println("Method without finals took " + tElapsed + " ms");
    }
}
